# -*- coding: utf-8 -*-
# @Time    : 2024/5/16 10:24
# @Author  : Alvin
# @File    : trace_job_status.py
import redis
import time
import json
'''
根据jobi
'''
redis_client = redis.StrictRedis(host='localhost', port=6379, db=4)

def check_scrapyd_job_status(job_id):
    while True:
        job_status_json = redis_client.get(job_id)
        if job_status_json:
            job_status_data = json.loads(job_status_json.decode())
            break
        time.sleep(5)  # 等待10秒再次检查
    return job_status_data